import { Handlers } from "$fresh/server.ts";

export const handler: Handlers = {
  GET(_, ctx) {
    const code = ctx.data.query.get("code");
    if (!code) {
      return new Response(JSON.stringify({
        code: 400,
        message: "code is required",
      }));
    }

    return new Response(JSON.stringify(ctx.data.query.toString()));
  },
  POST(_, ctx) {
    ctx.url.searchParams.forEach((value, key) => {
      console.log(key, value);
    });
    return new Response(JSON.stringify({
      code: 200,
      message: "ok",
    }));
  },
};
